bitkeeper revision 1.1040 (40e2a907DdoQGsSPReiCr496bEgtTQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 30 Jun 2004 11:50:31 +0000 (11:50 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 30 Jun 2004 11:50:31 +0000 (11:50 +0000)
Remove obsolete files.

.rootkeys
tools/examples/Makefile
tools/examples/defaults [deleted file]
tools/examples/democd [deleted file]
tools/examples/init.d/xendomains [deleted file]
tools/examples/netbsd [deleted file]
tools/examples/xc_dom_control.py [deleted file]
tools/examples/xc_dom_create.py [deleted file]

index 5045bae458d9c08ddb95cfa14e802e8e4866dc9a..feb8ec1995065d41089b6f71b9ada76491a03ac9 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3f776bd1Hy9rn69ntXBhPReUFw9IEA tools/Makefile
 401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile
 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
-401d7e16GS8YesM1zateRbaOoI6YLQ tools/examples/defaults
-401d7e16NoWaBGC1RXbBcqAOr5Uaag tools/examples/democd
 405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend
-40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains
-40278d91ZjLhxdjjrGe8HEdwHLj5xQ tools/examples/netbsd
 40e15b7edWEtBf_oe3eBwGKuh1dyzQ tools/examples/vifctl
-401d7e16NpnVrFSsR7lKKKfTwCYvWA tools/examples/xc_dom_control.py
-401d7e16RJj-lbtsVEjua6HYAIiKiA tools/examples/xc_dom_create.py
 40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmdefaults
 40dfd40auJwNnb8NoiSnRkvZaaXkUg tools/examples/xmnetbsd
 3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/libxc/Makefile
index 794933d5d63d12c84d7eaacc950cfc833d351637..4df04eed55bd88e23f7fea8d458ffe6f3fbee33e 100644 (file)
@@ -1,21 +1,17 @@
 
 INSTALL  = $(wildcard *.py)
 
-ETC     = defaults democd netbsd xmdefaults
+ETC     = xmdefaults
 ETCDIR   = /etc/xen
 
-INITD    = init.d/xendomains init.d/xend
+INITD    = init.d/xend
 
 XEND     = vifctl
 XEND_DIR = $(ETCDIR)/xend
 
 all: 
 
-install: all install-bin install-initd install-etc install-xend
-
-install-bin:
-       mkdir -p $(prefix)/usr/bin
-       install -m0755 $(INSTALL) $(prefix)/usr/bin
+install: all install-initd install-etc install-xend
 
 install-initd:
        mkdir -p $(prefix)/etc/init.d
@@ -36,5 +32,4 @@ install-xend:
            install -m0755 $$i $(prefix)$(XEND_DIR); \
        done
 
-
 clean:
diff --git a/tools/examples/defaults b/tools/examples/defaults
deleted file mode 100644 (file)
index 336be7c..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-import xenctl.ip
-
-##### Edit this python file to reflect the configuration of your system
-
-##### This example script expects a variable called 'vmid' to be set.
-
-def config_usage ():
-    print >>sys.stderr,"""
-The config file '%s' requires the following variable to be defined:
- vmid             -- Numeric identifier for the new domain, used to calculate
-                     the VM's IP address and root partition. E.g. -Dvmid=1
-""" % config_file
-
-
-try:
-    vmid=int(vmid) # convert to integer
-except:
-    print >>sys.stderr,"%s: This script expects 'vmid' to be set using -D vmid=X" % config_file
-    assert()
-
-if vmid == 0:
-    print >>sys.stderr,"%s: 'vmid' must be greater than 0" % config_file
-    assert()
-
-
-# STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
-image = "../../../install/boot/xenolinux.gz"
-ramdisk = ""
-#ramdisk = "/boot/initrd.gz"
-builder_fn='linux' # this is a linux domain
-
-# STEP 2. The initial memory allocation (in megabytes) for the new domain.
-mem_size = 64
-
-# STEP 3. A handy name for your new domain.
-domain_name = "This is VM %d" % vmid
-
-# STEP 4. Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
-cpu = vmid  # set based on vmid (mod number of CPUs)
-
-
-# STEP 5. Specify IP address(es), for the new domain.  You need to
-# configure IP addrs within the domain just as you do normally.  This
-# is just to let Xen know about them so it can route packets
-# appropriately.
-
-#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
-vfr_ipaddr  = [xenctl.ip.add_offset_to_ip(xenctl.ip.get_current_ipaddr(),vmid),
-              xenctl.ip.add_offset_to_ip('169.254.1.0',vmid),]
-
-
-# STEP 6. Identify any physcial partitions or virtual disks you want the
-# domain to have access to, and what you want them accessible as
-# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
-#       ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
-#       ('vd:as73gd784dh','hda1','w'),
-#       ('phy:cdrom','hdd','r')
-
-vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1','w' ), 
-            ('phy:sda6','sda6','r') ]
-
-
-
-# STEP 5b. Set the VBD expertise level.  Most people should leave this
-# on 0, at least to begin with - this script can detect most dangerous
-# disk sharing between domains and with this set to zero it will only
-# allow read only sharing.
-
-vbd_expert = 0
-
-
-# STEP 7. Build the command line for the new domain. Edit as req'd.
-# You only need the ip= line if you're NFS booting or the root file system
-# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
-# You can use 'extrabit' to set the runlevel and custom environment
-# variables used by custom rc scripts (e.g. VMID=, usr= )
-
-netmask = xenctl.ip.get_current_ipmask()
-gateway = xenctl.ip.get_current_ipgw()
-nfsserv = '169.254.1.0'  
-
-cmdline_ip = "ip="+vfr_ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
-cmdline_root = "root=/dev/sda1 ro"
-#cmdline_root = "root=/dev/nfs nfsroot=/full/path/to/root/directory"
-cmdline_extra = "4 VMID=%d usr=/dev/sda6" % vmid
-
-
-# STEP 8. Set according to whether you want the script to watch the domain 
-# and auto-restart it should it die or exit.
-
-auto_restart = False
-#auto_restart = True
-
-# STEP 9. (Optional) Define a console port number for the new domain.
-
-# console_port = 9610+vmid
diff --git a/tools/examples/democd b/tools/examples/democd
deleted file mode 100644 (file)
index b8e9c0c..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-
-##### Edit this python file to reflect the configuration of your system
-
-##### This example script requires variable 'ip' to be set, and optionally
-##### netmask and gatewaty for the kernel command line
-
-def config_usage ():
-    print >>sys.stderr, """
-The config file %s requires the following vars to be defined:
- ip               -- List of IP addr(s) for Xen to route to domain 
-                     e.g. '-Dip=1.2.3.4,5.6.7.8'
-The following variables may be optionally defined:
- mem              -- Adjust initial memory allocation (default 64MB)
- netmask          -- Override gateway for kernel ip= command line
- gateway          -- Override network for kernel ip= command line
-""" % config_file
-
-try:
-    ip
-except:
-    print "Set variable 'ip' using '-Dip=1.2.3.4,5.6.7.8'"
-    assert()
-
-# STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
-image   = "/boot/xenolinux.gz"
-ramdisk = "/boot/initrd.gz"
-builder_fn='linux' # this is a linux domain
-
-# STEP 2. The initial memory allocation (in megabytes) for the new domain.
-try:
-    mem_size = int(mem)
-except NameError:
-    mem_size = 64
-
-
-# STEP 3. A handy name for your new domain.
-# appends either first hostname or last quad of first IP address dependant on value passed
-
-quads = string.split(ip, '.')
-if len(quads) == 4:                                    # fragile heuristic for valid IP verification
-       domain_name = "Xen VM .%s" % quads[3]           # use last quad of IP
-else:
-       domain_name = "Xen VM: %s" % ip                 # use hostname passed in
-
-
-# STEP 4. Specify IP address(es), for the new domain.  You need to
-# configure IP addrs within the domain just as you do normally.  This
-# is just to let Xen know about them so it can route packets
-# appropriately.
-
-#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
-#vfr_ipaddr  = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid)]
-vfr_ipaddr  = map(socket.gethostbyname,string.split(ip,','))
-
-
-
-# STEP 5a. Identify any physcial partitions or virtual disks you want the
-# domain to have access to, and what you want them accessible as
-# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
-#       ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
-#       ('vd:as73gd784dh','hda1','w'),
-#       ('phy:cdrom','hdd','r')
-
-vbd_list = [ ('phy:cdrom','hdd','r' ) ]
-
-
-
-# STEP 5b. Set the VBD expertise level.  Most people should leave this
-# on 0, at least to begin with - this script can detect most dangerous
-# disk sharing between domains and with this set to zero it will only
-# allow read only sharing.
-
-vbd_expert = 0
-
-
-# STEP 6. Build the command line for the new domain. Edit as req'd.
-# You only need the ip= line if you're NFS booting or the root file system
-# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
-# You can use 'extrabit' to set the runlevel and custom environment
-# variables used by custom rc scripts (e.g. VMID=, usr= )
-
-
-# see if we have a local IP at all
-localip=''
-for i in vfr_ipaddr:
-    if xenctl.utils.check_subnet(i,'169.254.0.0','255.255.0.0'):
-       localip=i
-       break
-
-
-# if either netmask and gateway has been set from the command line,
-# associate it with the first IP address that has been specified.
-
-myip = ''
-
-try: 
-    netmask = socket.gethostbyname( netmask )
-    gateway = socket.gethostbyname( gateway )
-    myip = vfr_ipaddr[0]
-
-except NameError:
-    netmask = xenctl.utils.get_current_ipmask()
-    gateway = xenctl.utils.get_current_ipgw()
-
-# if we haven't got an address, see if we have one that matches the LAN
-
-if not myip:
-    if netmask and gateway:
-       for i in vfr_ipaddr:
-           if xenctl.utils.check_subnet(i,gateway,netmask): 
-               myip=i
-               break
-
-# if we still haven't got an address, see if there's a link local one
-
-if not myip and localip:
-    myip = localip
-    netmask = '255.255.0.0'
-    gateway = '169.254.1.0'
-
-
-# As a final fallback, through everything down the interface
-
-if not myip:
-    myip = vfr_ipaddr[0]
-    netmask = '0.0.0.0' 
-    gateway = '' 
-
-# Calculate the components with which we will build the command line
-
-nfsserv = '169.254.1.0'  
-
-cmdline_ip="ip="+myip+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
-cmdline_root  = "root=/dev/ram0 rw init=/linuxrc"
-
-if localip:
-    cmdline_extra = "4 LOCALIP=%s" % localip
-else:
-    cmdline_extra = "4"
-
-# STEP 7. Set according to whether you want the script to watch the domain 
-# and auto-restart it should it die or exit.
-
-auto_restart = False
-#auto_restart = True
diff --git a/tools/examples/init.d/xendomains b/tools/examples/init.d/xendomains
deleted file mode 100755 (executable)
index 41524e6..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/sh
-#
-# /etc/init.d/xendomains
-# Start / stop domains automatically when domain 0 boots / shuts down.
-#
-# chkconfig: 345 99 00
-# description: Start / stop Xen domains.
-#
-# This script offers fairly basic functionality.  It should work on Redhat
-# but also on LSB-compliant SuSE releases and on Debian with the LSB package
-# installed.  (LSB is the Linux Standard Base)
-#
-# Based on the example in the "Designing High Quality Integrated Linux
-# Applications HOWTO" by Avi Alkalay
-# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
-#
-
-RETVAL=0
-
-INITD=/etc/init.d/
-
-AUTODIR=/etc/xen/auto
-LOCKFILE=/var/lock/subsys/xendomains
-
-if [ -e /lib/lsb ]; then
-    # assume an LSB-compliant distro (Debian with LSB package,
-    # recent-enough SuSE, others...)
-
-    . /lib/lsb/init-functions # source LSB standard functions
-
-    on_fn_exit()
-    {
-       if [ $RETVAL -eq 0 ]; then
-           log_success_msg
-       else
-           log_failure_msg
-       fi
-    }
-else
-    # assume a Redhat-like distro
-    . $INITD/functions # source Redhat functions
-
-    on_fn_exit()
-    {
-       if [ $RETVAL -eq 0 ]; then
-           success
-       else
-           failure
-       fi
-       
-       echo
-    }
-fi
-
-
-
-start() {
-    if [ -f $LOCKFILE ]; then return; fi
-
-    echo -n $"Starting auto Xen domains:"
-
-    # We expect config scripts for auto starting domains to be in
-    # AUTODIR - they could just be symlinks to files elsewhere
-    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
-       touch $LOCKFILE
-       
-       # Create all domains with config files in AUTODIR.
-       for dom in  $AUTODIR/*; do
-           xm create --quiet --defaults $dom
-           if [ $? -ne 0 ]; then
-               RETVAL=$?
-           fi
-       done
-
-    fi
-
-    on_fn_exit
-}
-
-stop()
-{
-    # NB. this shuts down ALL Xen domains (politely), not just the ones in
-    # AUTODIR/*
-    # This is because it's easier to do ;-) but arguably if this script is run
-    # on system shutdown then it's also the right thing to do.
-    
-    echo -n $"Shutting down all Xen domains:"
-
-    xm shutdown --all --wait --norestart
-
-    RETVAL=$?
-
-    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
-
-    on_fn_exit
-}
-
-# This does NOT necessarily restart all running domains: instead it
-# stops all running domains and then boots all the domains specified in
-# AUTODIR.  If other domains have been started manually then they will
-# not get restarted.
-# Commented out to avoid confusion!
-#
-#restart()
-#{
-#    stop
-#    start
-#}
-
-# same as restart for now - commented out to avoid confusion
-#reload()
-#{
-#    restart
-#}
-
-
-case "$1" in
-    start)
-       start
-       ;;
-
-    stop)
-       stop
-       ;;
-
-# The following are commented out to disable them by default to avoid confusion
-# - see the notes above
-#
-#    restart)
-#      restart
-#      ;;
-#
-#    reload)
-#      reload
-#      ;;
-
-    status)
-       xm list
-       ;;
-
-    *)
-       echo $"Usage: $0 {start|stop|status}"
-       ;;
-esac
-
-exit $RETVAL
diff --git a/tools/examples/netbsd b/tools/examples/netbsd
deleted file mode 100644 (file)
index f3dcccb..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-
-##### Edit this python file to reflect the configuration of your system
-
-##### This example script expects a variable called 'vmid' to be set.
-
-def config_usage ():
-    print >>sys.stderr,"""
-The config file '%s' requires the following variable to be defined:
- vmid             -- Numeric identifier for the new domain, used to calculate
-                     the VM's IP address and root partition. E.g. -Dvmid=1
-
-Additionally the following variable may be defined:
- image            -- Path to kernel image, can be gzip'ed. [/boot/netbsd]
- mem              -- Memory size. [16]
- name             -- Domain name. [NetBSD VM vmid]
- ip               -- Primary IP address for domain. [this domain's IP + vmid]
- nfsserv          -- NFS server IP address. [169.254.1.0]
- nfsroot          -- Path to nfs root filesystem. [/netboot/netbsd]
-""" % config_file
-
-
-try:
-    vmid=int(vmid) # convert to integer
-except:
-    print >>sys.stderr,"%s: This script expects 'vmid' to be set using -D vmid=X" % config_file
-    assert()
-
-if vmid == 0:
-    print >>sys.stderr,"%s: 'vmid' must be greater than 0" % config_file
-    assert()
-
-
-# STEP 1. Specify kernel image file. Can be gzip'ed.
-if image == "": image = "/boot/netbsd"
-
-builder_fn='netbsd' # this is a NetBSD domain
-
-
-# STEP 2. The initial memory allocation (in megabytes) for the new domain.
-try:
-    mem_size = int(mem)
-except:
-    mem_size = 16
-
-
-# STEP 3. A handy name for your new domain.
-try:
-    domain_name = name
-except:
-    domain_name = "NetBSD VM %d" % vmid
-
-
-# STEP 4. Specify IP address(es), for the new domain.  You need to
-# configure IP addrs within the domain just as you do normally.  This
-# is just to let Xen know about them so it can route packets
-# appropriately.
-
-#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
-try:
-    vfr_ipaddr = [ip, xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
-except:
-    vfr_ipaddr = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),vmid),
-                  xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
-
-
-# STEP 5a. Identify any physcial partitions or virtual disks you want the
-# domain to have access to, and what you want them accessible as
-# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
-#       ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
-#       ('vd:as73gd784dh','hda1','w'),
-#       ('phy:cdrom','hdd','r')
-
-#vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1','w' ), 
-#           ('phy:sda6','sda6','r') ]
-
-
-
-# STEP 5b. Set the VBD expertise level.  Most people should leave this
-# on 0, at least to begin with - this script can detect most dangerous
-# disk sharing between domains and with this set to zero it will only
-# allow read only sharing.
-
-vbd_expert = 0
-
-
-# STEP 6. Build the command line for the new domain. Edit as req'd.
-# You only need the ip= line if you're NFS booting or the root file system
-# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
-# You can use 'extrabit' to set the runlevel and custom environment
-# variables used by custom rc scripts (e.g. VMID=, usr= )
-
-netmask = xenctl.utils.get_current_ipmask()
-gateway = xenctl.utils.get_current_ipgw()
-try:
-    nfsserv
-except:
-    nfsserv = '169.254.1.0'
-
-cmdline_ip = "ip="+vfr_ipaddr[0]+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
-try:
-    cmdline_root = "nfsroot="+nfsserv+":"+nfsroot
-except:
-    cmdline_root = "nfsroot="+nfsserv+":/netboot/netbsd"
-    #cmdline_root = "nfsroot=/full/path/to/root/directory"
-
-cmdline_extra = "bootdev=xennet0"
-
-
-# STEP 7. Set according to whether you want the script to watch the domain 
-# and auto-restart it should it die or exit.
-
-auto_restart = False
-#auto_restart = True
diff --git a/tools/examples/xc_dom_control.py b/tools/examples/xc_dom_control.py
deleted file mode 100755 (executable)
index 998c856..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/env python
-
-# usage: xc_dom_control [command] <params>
-#
-# this script isn't very smart, but it'll do for now.
-#
-
-def usage ():
-    print >>sys.stderr, """
-Usage: %s [command] <params>
-
-  pause     [dom]        -- pause a domain
-  unpause   [dom]        -- un-pause a domain
-  shutdown  [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
-                            (optionally wait for complete shutdown)
-  destroy   [dom]        -- immediately terminate a domain
-  pincpu    [dom] [cpu]  -- pin a domain to the specified CPU
-  suspend   [dom] [file] -- write domain's memory to a file and terminate
-                           (resume by re-running xc_dom_create with -L option)
-  unwatch   [dom]        -- kill the auto-restart daemon for a domain
-  list                   -- print info about all domains
-  listvbds               -- print info about all virtual block devs
-  cpu_bvtset [dom] [mcuadv] [warp] [warpl] [warpu]
-                         -- set BVT scheduling parameters for domain
-  cpu_bvtslice [slice]   -- set default BVT scheduler slice
-  cpu_atropos_set [dom] [period] [slice] [latency] [xtratime]
-                         -- set Atropos scheduling parameters for domain
-  cpu_rrobin_slice [slice] -- set Round Robin scheduler slice
-""" % sys.argv[0]
-
-import Xc, sys, re, string, time, os, signal
-
-if len(sys.argv) < 2:
-    usage()
-    sys.exit(-1)
-
-cmd = sys.argv[1]
-
-
-xc = Xc.new()
-rc = ''
-dom = None
-
-
-if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
-    dom = int(sys.argv[2])
-
-if cmd == 'pause':
-    rc = xc.domain_pause( dom=dom )
-
-elif cmd == 'unpause':
-    rc = xc.domain_unpause( dom=dom )    
-
-elif cmd == 'shutdown':
-    list = []
-    if dom != None:
-        rc = xc.domain_destroy( dom=dom ) # should be CMSG_SHUTDOWN
-        list.append(dom)
-    elif sys.argv[2] == 'all':
-        for i in xc.domain_getinfo():
-            if i['dom'] != 0: # don't shutdown dom0!
-                ret = xc.domain_destroy( dom=i['dom'] ) # should be CMSG_SHUTDOWN
-                if ret !=0: rc = ret
-                else: list.append(i['dom'])
-
-    if len(sys.argv) == 4 and sys.argv[3] == "-w":
-        # wait for all domains we shut down to terminate
-        for dom in list:
-            while True:
-                info = xc.domain_getinfo(dom,1)
-                if not ( info != [] and info[0]['dom'] == dom ): break
-                time.sleep(1)
-
-elif cmd == 'destroy':
-    rc = xc.domain_destroy( dom=dom )    
-
-elif cmd == 'pincpu':
-
-    if len(sys.argv) < 4:
-        usage()
-        sys.exit(-1)
-
-    cpu = int(sys.argv[3])
-    
-    rc = xc.domain_pincpu( dom, cpu )
-
-elif cmd == 'list':
-    print 'Dom  Name             Mem(kb)  CPU  State  Time(ms)'
-    for domain in xc.domain_getinfo():
-
-       run   = (domain['running'] and 'R') or 'r'
-        block = (domain['blocked'] and 'B') or 'b'
-       stop  = (domain['paused']  and 'P') or 'p'
-       susp  = (domain['shutdown'] and 'S') or 's'
-       crash = (domain['crashed'] and 'C') or 'c'
-
-        domain['state'] = run + block + stop + susp + crash
-        domain['cpu_time'] = domain['cpu_time']/1e6
-
-        print "%(dom)-4d %(name)-16s %(mem_kb)7d %(cpu)3d %(state)5s %(cpu_time)8d" % domain
-
-elif cmd == 'unwatch':
-
-    # the auto-restart daemon's pid file
-    watcher = '/var/run/xendomains/%d.pid' % dom
-
-    if os.path.isfile(watcher):
-        fd = open(watcher,'r')
-        pid = int(fd.readline())
-        os.kill(pid, signal.SIGTERM)
-
-elif cmd == 'listvbds':
-    print 'Dom   Dev   Perm   Size(MB)'
-    
-    for vbd in xc.vbd_probe():
-        vbd['size_mb'] = vbd['nr_sectors'] / 2048
-        vbd['perm'] = (vbd['writeable'] and 'w') or 'r'
-        print '%(dom)-4d  %(vbd)04x  %(perm)-1s      %(size_mb)d' % vbd
-
-elif cmd == 'suspend':
-    if len(sys.argv) < 4:
-        usage()
-        sys.exit(-1)
-
-    file = sys.argv[3]
-
-    # the auto-restart daemon's pid file
-    watcher = '/var/run/xendomains/%d.pid' % dom
-
-    if os.path.isfile(watcher):
-        fd = open(watcher,'r')
-        pid = int(fd.readline())
-        os.kill(pid, signal.SIGTERM)
-
-    rc = xc.linux_save( dom=dom, state_file=file, progress=1)
-
-elif cmd == 'cpu_bvtslice':
-    if len(sys.argv) < 3:
-        usage()
-        sys.exit(-1)
-
-    slice = dom # first int argument is in "dom" (!)
-
-    rc = xc.bvtsched_global_set(ctx_allow=slice)
-
-elif cmd == 'cpu_bvtset':
-    if len(sys.argv) < 7:
-        usage()
-        sys.exit(-1)
-
-    mcuadv = int(sys.argv[3])
-    warp   = int(sys.argv[4])
-    warpl  = int(sys.argv[5])
-    warpu  = int(sys.argv[6])
-
-    rc = xc.bvtsched_domain_set(dom=dom, mcuadv=mcuadv, warp=warp,
-                                warpl=warpl, warpu=warpu)
-
-elif cmd == 'cpu_atropos_set': # args: dom period slice latency xtratime
-    if len(sys.argv) < 6:
-        usage()
-        sys.exit(1)
-
-    (period, slice, latency, xtratime) = map(lambda x: int(x), sys.argv[3:7])
-    
-    rc = xc.atropos_domain_set(dom, period, slice, latency, xtratime)
-
-elif cmd == 'cpu_rrobin_slice':
-    rc = xc.rrobin_global_set(slice=int(sys.argv[2]))
-
-else:
-    usage()
-    sys.exit(-1)
-
-if rc != '':
-    print "return code %d" % rc
diff --git a/tools/examples/xc_dom_create.py b/tools/examples/xc_dom_create.py
deleted file mode 100755 (executable)
index bb3f441..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-#!/usr/bin/env python
-
-import string, sys, os, time, socket, getopt, signal, syslog
-import Xc, xenctl.utils, xenctl.console_client, re
-
-config_dir  = '/etc/xc/'
-config_file = xc_config_file = config_dir + 'defaults'
-
-def main_usage ():
-    print >>sys.stderr,"""
-Usage: %s <args>
-
-This tool is used to create and start new domains. It reads defaults
-from a file written in Python, having allowed variables to be set and
-passed into the file. Further command line arguments allow the
-defaults to be overridden. The defaults for each parameter are listed
-in [] brackets. Arguments are as follows:
-
-Arguments to control the parsing of the defaults file:
- -f config_file   -- Use the specified defaults script. 
-                     Default: ['%s']
- -L state_file    -- Load virtual machine memory state from state_file
- -D foo=bar       -- Set variable foo=bar before parsing config
-                     E.g. '-D vmid=3;ip=1.2.3.4'
- -h               -- Print extended help message, including all arguments
- -n               -- Dry run only, don't actually create domain
- -q               -- Quiet - write output only to the system log
- -s               -- Don't start the domain, just build it.
-""" % (sys.argv[0], xc_config_file)
-
-def extra_usage ():
-    print >>sys.stderr,"""
-Arguments to override current config read from '%s':
- -c               -- Turn into console terminal after domain is created
- -k image         -- Path to kernel image ['%s']
- -r ramdisk       -- Path to ramdisk (or empty) ['%s']
- -b builder_fn    -- Function to use to build domain ['%s']
- -m mem_size      -- Initial memory allocation in MB [%dMB]
- -N domain_name   -- Set textual name of domain ['%s']
- -a auto_restart  -- Restart domain on exit, yes/no ['%d']
- -e vbd_expert    -- Saftey catch to avoid some disk accidents ['%d'] 
- -d udisk,dev,rw  -- Add disk, partition, or virtual disk to domain. E.g. to 
-                     make partion sda4 available to the domain as hda1 with 
-                     read-write access: '-d phy:sda4,hda1,rw' To add 
-                     multiple disks use multiple -d flags or seperate with ';'
-                     Default: ['%s']
- -i vfr_ipaddr    -- Add IP address to the list which Xen will route to
-                     the domain. Use multiple times to add more IP addrs.
-                    Default: ['%s']
-
-Args to override the kernel command line, which is concatenated from these:
- -I cmdline_ip    -- Override 'ip=ipaddr:nfsserv:gateway:netmask::eth0:off'
-                     Default: ['%s']
- -R cmdline_root  -- Override root device parameters.
-                     Default: ['%s']
- -E cmdline_extra -- Override extra kernel args and rc script env vars.
-                     Default: ['%s']
-
-""" % (config_file,
-       image, ramdisk, builder_fn, mem_size, domain_name, auto_restart,
-       vbd_expert, 
-       printvbds( vbd_list ), 
-       reduce ( (lambda a,b: a+':'+b), vfr_ipaddr,'' )[1:],
-       cmdline_ip, cmdline_root, cmdline_extra)
-
-def config_usage (): pass
-
-def answer ( s ):
-    s = string.lower(s)
-    if s == 'yes' or s == 'true' or s == '1': return 1
-    return 0
-
-def printvbds ( v ):
-    s=''
-    for (a,b,c) in v:
-       s = s + '; %s,%s,%s' % (a,b,c)
-    return s[2:]
-
-def output(string):
-    global quiet
-    syslog.syslog(string)
-    if not quiet:
-        print string
-    return
-
-bail=False; dryrun=False; extrahelp=False; quiet = False
-image=''; ramdisk=''; builder_fn=''; restore=0; state_file=''
-mem_size=0; domain_name=''; vfr_ipaddr=[];
-vbd_expert=0; auto_restart=False;
-vbd_list = []; cmdline_ip = ''; cmdline_root=''; cmdline_extra=''
-pci_device_list = []; console_port = -1
-auto_console = False
-dontstart = False
-flags = 0
-
-##### Determine location of defaults file
-#####
-
-try:
-    opts, args = getopt.getopt(sys.argv[1:], "h?nqcsf:D:k:r:b:m:N:a:e:d:i:I:R:E:L:" )
-
-    for opt in opts:
-       if opt[0] == '-f': config_file= opt[1]
-       if opt[0] == '-h' or opt[0] == '-?' : bail=True; extrahelp=True
-       if opt[0] == '-n': dryrun=True
-       if opt[0] == '-D': 
-           for o in string.split( opt[1], ';' ):
-               (l,r) = string.split( o, '=' )
-               exec "%s='%s'" % (l,r)
-        if opt[0] == '-q': quiet = True
-        if opt[0] == '-L': restore = True; state_file = opt[1]
-        if opt[0] == '-s': dontstart = True
-
-
-except getopt.GetoptError:
-    bail=True
-
-
-try:
-    os.stat( config_file )
-except:
-    try:
-       d = config_dir + config_file
-       os.stat( d )
-       config_file = d
-    except:
-       print >> sys.stderr, "Unable to open config file '%s'" % config_file
-       bail = True
-
-
-##### Parse the config file
-#####
-
-if not quiet:
-    print "Parsing config file '%s'" % config_file
-
-try:
-    execfile ( config_file )
-except (AssertionError,IOError):
-    print >>sys.stderr,"Exiting %s" % sys.argv[0]
-    bail = True
-
-##### Print out config if necessary 
-##### 
-
-if bail:
-    main_usage()
-    config_usage()
-    if extrahelp: extra_usage()
-    sys.exit(1)
-
-##### Parse any command line overrides 
-##### 
-
-x_vbd_list = []
-x_vfr_ipaddr  = []
-
-for opt in opts:
-    if opt[0] == '-k': image = opt[1]
-    if opt[0] == '-r': ramdisk = opt[1]
-    if opt[0] == '-b': builder_fn = opt[1]  
-    if opt[0] == '-m': mem_size = int(opt[1])
-    if opt[0] == '-C': cpu = int(opt[1])
-    if opt[0] == '-N': domain_name = opt[1]
-    if opt[0] == '-a': auto_restart = answer(opt[1])
-    if opt[0] == '-e': vbd_expert = answer(opt[1])
-    if opt[0] == '-I': cmdline_ip = opt[1]
-    if opt[0] == '-R': cmdline_root = opt[1]
-    if opt[0] == '-E': cmdline_extra = opt[1]
-    if opt[0] == '-i': x_vfr_ipaddr.append(opt[1])
-    if opt[0] == '-c': auto_console = True
-    if opt[0] == '-d':
-       try:
-           vv = string.split(opt[1],';')           
-           for v in vv:
-               (udisk,dev,mode) = string.split(v,',')
-               x_vbd_list.append( (udisk,dev,mode) )
-       except:
-           print >>sys.stderr, "Invalid block device specification : %s" % opt[1]
-           sys.exit(1)
-
-if x_vbd_list: vbd_list = x_vbd_list
-if x_vfr_ipaddr: vfr_ipaddr = x_vfr_ipaddr
-
-cmdline = cmdline_ip +' '+ cmdline_root +' '+ cmdline_extra
-
-syslog.openlog('xc_dom_create.py %s' % config_file, 0, syslog.LOG_DAEMON)
-
-##### Print some debug info just in case things don't work out...
-##### 
-
-output('VM image           : "%s"' % image)
-output('VM ramdisk         : "%s"' % ramdisk)
-output('VM memory (MB)     : "%d"' % mem_size)
-output('VM IP address(es)  : "%s"'
-                % reduce((lambda a,b: a+'; '+b),vfr_ipaddr,'' )[2:])
-output('VM block device(s) : "%s"' % printvbds( vbd_list ))
-output('VM cmdline         : "%s"' % cmdline)
-
-if dryrun:
-    sys.exit(1)
-
-##### Code beyond this point is actually used to manage the mechanics of
-##### starting (and watching if necessary) guest virtual machines.
-
-# Obtain an instance of the Xen control interface
-xc = Xc.new()
-
-# This function creates, builds and starts a domain, using the values
-# in the global variables, set above.  It is used in the subsequent
-# code for starting the new domain and rebooting it if appropriate.
-def make_domain():
-    """Create, build and start a domain.
-    Returns: [int] the ID of the new domain.
-    """
-
-    # set up access to the global variables declared above
-    global image, ramdisk, mem_size, cpu, domain_name, vfr_ipaddr, netmask
-    global vbd_list, cmdline, xc, vbd_expert, builder_fn
-       
-    if not os.path.isfile( image ):
-        print "Image file '" + image + "' does not exist"
-        sys.exit()
-
-    if ramdisk and not os.path.isfile( ramdisk ):
-        print "Ramdisk file '" + ramdisk + "' does not exist"
-        sys.exit()
-
-    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name, cpu=cpu )
-    if id <= 0:
-       print "Error creating domain"
-       sys.exit()
-
-    cmsg = 'new_control_interface(dom='+str(id)+', console_port='+str(console_port)+')'
-
-    cons_response = xenctl.utils.xend_control_message(cmsg)
-
-    if not cons_response['success']:
-       print "Error creating initial event channel"
-       print "Error type: " + cons_response['error_type']
-       if cons_response['error_type'] == 'exception':
-           print "Exception type: " + cons_response['exception_type']
-           print "Exception value: " + cons_response['exception_value']
-       xc.domain_destroy ( dom=id )
-       sys.exit()
-
-    if restore:
-        ret = eval('xc.%s_restore ( dom=id, state_file=state_file, progress=1)' % (builder_fn) )
-        if ret < 0:
-            print "Error restoring domain"
-            print "Return code = " + str(ret)
-            xc.domain_destroy ( dom=id )
-            sys.exit()
-    else:
-
-        ret = eval('xc.%s_build ( dom=id, image=image, ramdisk=ramdisk, cmdline=cmdline, control_evtchn=cons_response["remote_port"], flags=flags )' % builder_fn )
-        if ret < 0:
-            print "Error building Linux guest OS: "
-            print "Return code = " + str(ret)
-            xc.domain_destroy ( dom=id )
-            sys.exit()
-
-    # setup the virtual block devices
-
-    # set the expertise level appropriately
-    xenctl.utils.VBD_EXPERT_MODE = vbd_expert
-
-    if not (flags & 1<<4): # It's not a block backend (or it's old IO world)
-        cmsg = 'new_block_interface(dom='+str(id)+')'
-        xend_response = xenctl.utils.xend_control_message(cmsg)
-        if not xend_response['success']:
-            print "Error creating block interface"
-            print "Error type: " + xend_response['error_type']
-            if xend_response['error_type'] == 'exception':
-                print "Exception type: " + xend_response['exception_type']
-                print "Exception val:  " + xend_response['exception_value']
-            xc.domain_destroy ( dom=id )
-            sys.exit()
-
-        for ( uname, virt_name, rw ) in vbd_list:
-            virt_dev = xenctl.utils.blkdev_name_to_number( virt_name )
-
-            segments = xenctl.utils.lookup_disk_uname( uname )
-            if not segments:
-                print "Error looking up %s\n" % uname
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-
-            if len(segments) > 1:
-                print "New I/O world cannot deal with multi-extent vdisks"
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-            seg = segments[0]
-            cmsg = 'new_block_device(dom=' + str(id) + \
-                   ',handle=0,vdev=' + str(virt_dev) + \
-                   ',pdev=' + str(seg['device']) + \
-                   ',start_sect=' + str(seg['start_sector']) + \
-                   ',nr_sect=' + str(seg['nr_sectors']) + \
-                   ',readonly=' + str(not re.match('w',rw)) + ')'
-            xend_response = xenctl.utils.xend_control_message(cmsg)
-            if not xend_response['success']:
-                print "Error creating virtual block device"
-                print "Error type: " + xend_response['error_type']
-                if xend_response['error_type'] == 'exception':
-                    print "Exception type: " + xend_response['exception_type']
-                    print "Exception val:  " + xend_response['exception_value']
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-    else: # It's a block backend - notify Xend.
-        cmsg = 'set_block_backend(dom='+str(id)+')'
-        xend_response = xenctl.utils.xend_control_message(cmsg)
-        if not xend_response['success']:
-            print "Error registering network backend"
-            print "Error type: " + xend_response['error_type']
-            if xend_response['error_type'] == 'exception':
-                print "Exception type: " + xend_response['exception_type']
-                print "Exception val:  " + xend_response['exception_value']
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-
-    if not (flags & 1<<5): # If it's not the net backend, give it a frontend.
-        cmsg = 'new_network_interface(dom='+str(id)+')'
-        xend_response = xenctl.utils.xend_control_message(cmsg)
-        if not xend_response['success']:
-            print "Error creating network interface"
-            print "Error type: " + xend_response['error_type']
-            if xend_response['error_type'] == 'exception':
-                print "Exception type: " + xend_response['exception_type']
-                print "Exception val:  " + xend_response['exception_value']
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-    else: # It's a new net backend - notify Xend.
-        cmsg = 'set_network_backend(dom='+str(id)+')'
-        xend_response = xenctl.utils.xend_control_message(cmsg)
-        if not xend_response['success']:
-            print "Error registering network backend"
-            print "Error type: " + xend_response['error_type']
-            if xend_response['error_type'] == 'exception':
-                print "Exception type: " + xend_response['exception_type']
-                print "Exception val:  " + xend_response['exception_value']
-                xc.domain_destroy ( dom=id )
-                sys.exit()
-
-    # check for physical device access
-    for (pci_bus, pci_dev, pci_func) in pci_device_list:
-        if xc.physdev_pci_access_modify(
-            dom=id, bus=pci_bus, dev=pci_dev,
-            func=pci_func, enable=1 ) < 0:
-            print "Non-fatal error enabling PCI device access."
-        else:
-            print "Enabled PCI access (%d:%d:%d)." % \
-                  (pci_bus,pci_dev,pci_func)
-               
-    if restore:
-       # send an unsolicited ARP reply for all non link-local IPs
-       gw=xenctl.utils.get_current_ipgw()
-       if gw == '': gw='255.255.255.255'
-       nlb=open('/proc/sys/net/ipv4/ip_nonlocal_bind','r').read()[0]=='1'
-       if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '1'
-       for ip in vfr_ipaddr:
-           if not xenctl.utils.check_subnet(ip,'169.254.0.0','255.255.0.0'):
-               print     '/usr/sbin/arping -A -b -I eth0 -c 1 -s %s %s' % (ip,gw)
-               os.system('/usr/sbin/arping -A -b -I eth0 -c 1 -s %s %s' % (ip,gw))
-       if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '0'
-
-    if not dontstart:
-        if xc.domain_unpause( dom=id ) < 0:
-            print "Error starting domain"
-            xc.domain_destroy ( dom=id )
-            sys.exit()
-
-    return (id, cons_response['console_port'])
-# end of make_domain()
-
-def mkpidfile():
-    global current_id
-    if not os.path.isdir('/var/run/xendomains/'):
-        os.mkdir('/var/run/xendomains/')
-
-    fd = open('/var/run/xendomains/%d.pid' % current_id, 'w')
-    print >> fd, str(os.getpid())
-    fd.close()
-    return
-
-def rmpidfile():
-    global current_id
-    os.unlink('/var/run/xendomains/%d.pid' % current_id)
-
-def death_handler(dummy1,dummy2):
-    global current_id
-    os.unlink('/var/run/xendomains/%d.pid' % current_id)
-    output('Auto-restart daemon: daemon PID = %d for domain %d is now exiting'
-              % (os.getpid(),current_id))
-    sys.exit(0)
-    return
-
-# The starting / monitoring of the domain actually happens here...
-
-# start the domain and record its ID number
-(current_id, current_port) = make_domain()
-output("VM started in domain %d. Console I/O available on TCP port %d." % (current_id,current_port))
-
-if auto_console:
-    xenctl.console_client.connect('127.0.0.1',int(current_port))
-
-# if the auto_restart flag is set then keep polling to see if the domain is
-# alive - restart if it is not by calling make_domain() again (it's necessary
-# to update the id variable, since the new domain may have a new ID)
-
-if auto_restart:
-    # turn ourselves into a background daemon
-    try:
-       pid = os.fork()
-       if pid > 0:
-           sys.exit(0)
-       os.setsid()
-       pid = os.fork()
-       if pid > 0:
-            output('Auto-restart daemon PID = %d' % pid)
-           sys.exit(0)
-        signal.signal(signal.SIGTERM,death_handler)
-    except OSError:
-       print >> sys.stderr, 'Problem starting auto-restart daemon'
-       sys.exit(1)
-
-    mkpidfile()
-
-    while True:
-       time.sleep(1)
-        info = xc.domain_getinfo(current_id, 1)
-       if info == [] or info[0]['dom'] != current_id:
-           output("Auto-restart daemon: Domain %d has terminated, restarting VM in new domain"
-                                     % current_id)
-            rmpidfile()
-           (current_id, current_port) = make_domain()
-            mkpidfile()
-           output("Auto-restart daemon: VM restarted in domain %d. Console on port %d." % (current_id,current_port))